<?php
class Aaron_Sales_Model_Observer
{
	public function validateMaxQtyCartUpdateBefore(Varien_Event_Observer $observer){
		$warning = 'Error';
		$info = $observer->getEvent()->getInfo();
		$qty = 0;
		foreach($info as $v){
			$qty += $v['qty'];
		}
		$error_message = Mage::getStoreConfig('sales/maximum_order/error_message');
		$max_order_items = Mage::getStoreConfig('sales/maximum_order/items');
		if($qty>$max_order_items and $max_order_items>0)
			throw new Exception($error_message);
	}
	
	public function validateMaxQtyCartAddBefore(Varien_Event_Observer $observer){
		$qty = $observer->getEvent()->getCart()->getSummaryQty();
		$info = $observer->getEvent()->getParams();	
		$warning = 'Error';
		$qty += $info['qty'];
		$error_message = Mage::getStoreConfig('sales/maximum_order/error_message');
		$max_order_items = Mage::getStoreConfig('sales/maximum_order/items');
		if($qty>$max_order_items and $max_order_items>0)
			throw new Exception($error_message);
	}
}